/*
 * @Descripttion:
 * @version:
 * @Author: Mak
 * @Date: 2020-06-22 09:29:34
 * @LastEditors: Mak
 * @LastEditTime: 2021-03-09 10:44:52
 */
import Cookies from 'js-cookie'
import * as stn from "@/constants/storeName";

const TokenKey = stn.TOKEN

export function getToken() {
  return Cookies.get(TokenKey)
}
export function setToken(token) {
  return Cookies.set(TokenKey, token)
}
export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getCheckPassword() {
  return Cookies.get('checkPassword')
}

// 存缓存
export function setCookies(key, value) {
  Cookies.set(key, value)
}
// 获取缓存
export function getCookies(key) {
  return Cookies.get(key)
}
// 删除缓存
export function removeCookies(key) {
  Cookies.remove(key)
}

export function getLoginType() {
  return Cookies.get('login-type')
}

export function setLoginType(type) {
  return Cookies.set('login-type', type)
}


// 存缓存
export function setStorage(key, value) {
  sessionStorage.setItem(key, JSON.stringify(value))
}
// 获取缓存
export function getStorage(key) {
  return JSON.parse(sessionStorage.getItem(key))
}
// 删除缓存
export function removeStorage(key) {
  sessionStorage.removeItem(key);
}

// 设置localStorage
export function setLocalStorage(key, value) {
   localStorage.setItem(key, JSON.stringify(value))
}
// 获取localStorage
export function getLocalStorage(key) {
  return localStorage.getItem(key)
}
// 删除localStorage
export function removeLocalStorage(key) {
  localStorage.removeItem(key)
}
